package com.tcm.logistics.service.impl;

import com.base.core.pager.PageBean;
import com.base.core.pager.PageContext;
import com.tcm.logistics.dao.mapper.LogisticsMapper;
import com.tcm.logistics.entity.Logistics;
import com.tcm.logistics.service.LogisticsService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService(version = "0.0.1-alpha")
public class LogisticsServiceImpl implements LogisticsService {

    @Autowired
    private LogisticsMapper logisticsMapper;

    /**
     * 物流发货单列表
     *
     * @param start
     * @param pagesize
     * @return
     */
    @Override
    public PageBean<Logistics> listPageLogistics(Long start, Long pagesize) {
        List<Logistics> logisticsList = logisticsMapper.listPageLogistics(start,pagesize);
        PageBean<Logistics> logisticsPageBean = new PageBean<Logistics>(logisticsList,
                PageContext.getDataCount(), start, pagesize);
        return logisticsPageBean;
    }

    @Override
    public Logistics findLogisticsById(Long id) {
        return logisticsMapper.findByKey(id);
    }

    /**
     * 新增物流订单
     *
     * @param logistics
     */
    @Override
    public void create(Logistics logistics) {
        logisticsMapper.insert(logistics);
    }

    /**
     * 更新物流订单
     *
     * @param logistics
     */
    @Override
    public void update(Logistics logistics) {
        logisticsMapper.updateByKey(logistics);
    }

    /**
     * 逻辑删除物流订单
     *
     * @param id
     * @return
     */
    @Override
    public int deleteLogicById(Long id) {
        return logisticsMapper.deleteLogicByKey(id);
    }

    /**
     * 删除物流订单
     *
     * @param id
     * @return
     */
    @Override
    public int deleteById(Long id) {
        return logisticsMapper.deleteByKey(id);
    }
}
